package org.example.entity;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Product {
    private int proId;
    private String proName;
    private int stock;
    private double price;

    public Product() {
    }

    public Product(int proId, String proName, int stock, double price) {
        this.proId = proId;
        this.proName = proName;
        this.stock = stock;
        this.price = price;
    }

    public Product(String proName, int stock, double price) {
        this.proName = proName;
        this.stock = stock;
        this.price = price;
    }

    public int getProId() {
        return proId;
    }

    public void setProId(int proId) {
        this.proId = proId;
    }

    public String getProName() {
        return proName;
    }

    public void setProName(String proName) {
        this.proName = proName;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Product{" +
                "proId=" + proId +
                ", proName='" + proName + '\'' +
                ", stock=" + stock +
                ", price=" + price +
                '}';
    }

    public static Product map(ResultSet rs) throws SQLException {
        return new Product(
                rs.getInt("pro_id"),
                rs.getString("pro_name"),
                rs.getInt("stock"),
                rs.getDouble("price")
        );
    }
}
